#pragma once
#include "datastruct.h"

typedef std::map<UINT, void*>::iterator PI2P;
typedef std::map<UINT, BYTE>::iterator PI2C;
typedef 	std::map<void*,UINT>::iterator PP2I;

class ResourceManager
{
	std::map<UINT, void*> ID2PTR;
	std::map<void*,UINT > PTR2ID;
	std::map<UINT, BYTE> ID2CNT;

	WCHAR	ObjPath[MAX_PATH];
	int ObjCnt;
	UINT UnhandledId;
public:
	//objects functions
	HBITMAP LoadBmp(UINT id_i);
	HBITMAP CreateBufferBmp(UINT width_i, UINT height_i);
	WCHAR* LoadObjStr(UINT id_i);

	UINT UnloadObjStr(UINT id_i);
	UINT UnloadBmp(UINT id_i);
	UINT UnloadBmp(HBITMAP& hbm_io);

	//function
	bool Initiate(HINSTANCE h_i);
	PWCHAR GetObjectPath(size_t& cnt_o= uiNULL);
	ResourceManager(HINSTANCE h);
};


typedef	std::pair <KEY_ID, PLR_ID> KeyPlayer;   // BYTE:  FF  PlayerId KeyArr
class InputData{
	static const int	nP = 2;//not likely should be changed neither...
	static const int	MaxPlayer_Idx = 1;//not likely should be changed...

	//a input 2 key map
	std::map<WCHAR, KeyPlayer> Inp2KeyPlayer;
	std::map<KEY_ID, WCHAR>Key2Name;

	UINT PlayerInput[nP]; //mixed keys
	UINT GetInputOnce[nP]; //mixed keys

	void SetKey2Name();
	void LoadPlayerKeys( );
	void OutPutDebugKeys();
public:
	double LastPushTime[nP];
	void PushKey(BYTE Inp_i, BOOL down_i);
	bool IsKeyDown(PLR_ID PlayerId_i, KEY_ID KeyId_i){ return (KeyId_i & PlayerInput[PlayerId_i]) == KeyId_i;}
	bool IsKeyDown_Once(PLR_ID PlayerId_i, KEY_ID KeyId_i);
	KEY_ID GetDirectionKeyByOrder(PLR_ID PlayerId_i);
	KEY_ID GetActionKeys(PLR_ID PlayerId_i);

public:
	InputData();
	~InputData();
	void Clean();
};
